#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    vector<int> missingTwo(vector<int>& nums) {
        vector<int> ret(2);

        int n = nums.size() + 2;
        int tmp = 0;
        for (int i = 1; i <= n; i++)
            tmp ^= i;
        for (auto& i : nums)
            tmp ^= i;

        unsigned int dif = tmp & -tmp;
        for (int i = 1; i <= n; i++)
        {
            if (i & dif)
                ret[0] ^= i;
            else
                ret[1] ^= i;
        }
        for (auto& i : nums)
        {
            if (i & dif)
                ret[0] ^= i;
            else
                ret[1] ^= i;
        }

        return ret;
    }
};

